package com.gongzhiyun.springboot3test.mapper.novel;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gongzhiyun.springboot3test.entity.novel.NovelUserRatings;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface NovelUserRatingsMapper extends BaseMapper<NovelUserRatings> {

    //计算某部小说的平均分
    @Select("select ROUND(avg(user_rating),1)  from novel_user_ratings where novel_id=#{novelId}")
    Double getAvgRating(Integer novelId);

    @Select("select count(*) from novel_user_ratings where novel_id=#{novelId}")
    Integer getRatingCount(Integer novelId);
}
